package com.bjsxt.thread;

public class SetNameThread {

    public static void main(String[] args) {
        SetName1 s =new SetName1("setname1");
        s.start();

        SetName1 s2 = new SetName1();
        s2.setName("s2setname1");
        s2.start();

        Thread s3 = new Thread(new SetName2());
        s3.setName("s3setname2");
        s3.start();

    }
}

class SetName1 extends Thread{
    @Override
    public void run() {
        System.out.println(this.getName());
    }
    public  SetName1(String name){
        super(name);
    }
    public SetName1(){}
}

class SetName2 implements Runnable{

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
    }
}


